home *** CD-ROM | disk | FTP | other *** search
- Path: pegasus.montclair.edu!harmon
- From: harmon@pegasus.montclair.edu (Derek Harmon)
- Newsgroups: comp.lang.c
- Subject: Re: What the heck is ...?
- Date: 12 Feb 1996 17:43:44 -0500
- Organization: Montclair State University
- Message-ID: <harmon.824164401@pegasus.montclair.edu>
- References: <sconi-1102961642580001@ip-24.newportnet.net> <4fmlro$nfg_001@pr.mcs.net>
- NNTP-Posting-Host: pegasus.montclair.edu
- X-Newsreader: NN version 6.5.0 #68 (NOV)
-
- mdp@mika-sys.com (Michael D. Perry) writes:
- > sconi@superstore.com (Chris Tiee "Chochoni Boboni") wrote:
- >>Here's something all the books love to avoid: The use of ... in
- >function
- >>declarations. For example, one book says that the prototype of
- >printf() is
- >>
- >>int printf(const char *fmt_string, ...);
- >>
-
- >What the ellipses mean is that it is a repeatable item. In the
- >case that you cite it takes the place of saying that all of the
- >following statements are valid:
-
- "Repeatable" is incorrect. The following statement will never compile,
-
- >printf("%d, ..., %d", 1 ... 7);
-
- The first reason it won't compile is it isn't C, the second reason it
- won't compile is because it is impossible for a compiler to have any grasp
- of what lies between the %d's and the 1 thru 7.
-
- The ellipsis is used in function headings and prototypes to signify that
- a variable number (0 or greater) of arguments of nondescript type follow.
- This is what gives printf() and sscanf() the power they have, since it is
- the fmt_string that specifies how many arguments printf() should expect.
- Using the functions in the <stdarg.h> library, it is possible to write
- C functions which can handle a variable number of arguments, as long as
- the function can tell how many arguments it should expect.
-
- -- Stone
- --
- # Derek Harmon (aka Stonelight) harmon@pegasus.montclair.edu
- # - Computer Science Undergrad, Montclair State University, NJ
- # - My views are my own, nobody else is this creative. 3;)>
- ... Where there's a will, there's an inheritance tax.
-